package objectfocus;

public class Student{
    //成员变量 是实例变量，每个实例有自己的一份
    String name;
    private int age;
    private String gender;

    //static 修饰的成员变量 是静态变量,各个实例可以共享，优先于实例加载在堆内存中
    public static String teacherName;
    //static 修饰的成员方法 是静态方法，静态方法只能访问静态变量，不能访问实例变量
    //静态方法中只能访问静态，非静态方法中既可以访问静态也可以访问非静态，静态中没有关键字 this

    public Student() {
    }
    public static void test(){
        System.out.println(teacherName);
    }

    public Student(String name, String gender,int age) {
        this.name = name;
        this.age = age;
        this.gender = gender;
    }

    /**
     * 获取
     * @return name
     */
    public String getName() {
        return name;
    }

    /**
     * 设置
     * @param name
     */
    public void setName(String name) {
        this.name = name;
    }

    /**
     * 获取
     * @return age
     */
    public int getAge() {
        return age;
    }

    /**
     * 设置
     * @param age
     */
    public void setAge(int age) {
        this.age = age;
    }

    /**
     * 获取
     * @return gender
     */
    public String getGender() {
        return gender;
    }

    /**
     * 设置
     * @param gender
     */
    public void setGender(String gender) {
        this.gender = gender;
    }

    public String toString() {
        return "Student{name = " + name + ", age = " + age + ", gender = " + gender + "}";
    }
    public void someOneStudy(){
        System.out.println(name + "正在学习");
    }
    public void show() {
        System.out.println(name+" "+gender+" "+age+" "+teacherName);
    }
}
